package com.hmall.order.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hmall.order.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderMapper extends BaseMapper<Order> {

    void addOrder(@Param("orderId")Long orderId,@Param("totalFee") Long totalFee,@Param("paymentType") Integer paymentType, @Param("userId") Long userId);

    Long findOrderIDByUserId(Long userId);

    @Select("select * from tb_order where id = #{orderId}")
    Order findOrderByOrderId(Long orderId);



    /**
     * 修改订单状态
     * @param id
     */
    @Update("update tb_order set status = #{status} where id = #{id}")
    void updateOrderStateByOrderId(@Param("status") Integer status,@Param("id") Long id);

    /**
     * 拿到所有状态为1的订单
     * @param status
     * @return
     */
    @Select("select * from tb_order where status = 1")
    List<Order> getOrderByState(Integer status);
}
